package com.jin_mo.custom.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.WindowManager;

import androidx.annotation.NonNull;

import com.moudle.custom.R;

/**
 * @date:2021/7/13-3:32 下午
 * @author: jin-mo
 * @description: 自定义样式弹窗
 */
public class PrivacyDialog extends Dialog {

    public PrivacyDialog(@NonNull Context context, int layoutResId, boolean cancelable) {
        super(context, R.style.PrivacyThemeDialog);
        setContentView(layoutResId);
        setCancelable(false);
        setCanceledOnTouchOutside(cancelable);
    }

    /**
     * * @param context 上下文
     *
     * @param resource   资源 layout布局
     * @param cancelable 点击弹窗外部是否消失
     * @param gravity    方向
     * @param width      宽
     * @param height     高
     */
    public PrivacyDialog(Context context,
                         int resource,
                         boolean cancelable,
                         int gravity,
                         int width,
                         int height) {
        super(context, R.style.PrivacyThemeDialog);
        setContentView(resource);
        setCanceledOnTouchOutside(cancelable);
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.width = width;
        layoutParams.height = height;
//        layoutParams.y = 180;//距离顶部的距离
        getWindow().setAttributes(layoutParams);
        getWindow().setGravity(gravity);
//        动画
        getWindow().setWindowAnimations(R.style.AnimBottom);
        show();
    }
}
